﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace TELOS_Konverter
{
    class MessageHandler
    {
        public const int STATUS_PROGRESS = 1;
        public const int STATUS_ERROR = 2;

        /// <summary>
        /// Display an error message with only the exception message
        /// </summary>
        /// <param name="e">Exception</param>
        public void displayError(Exception e)
        {
            alert(e.Message.ToString());
        }

        /// <summary>
        /// Display an error together with a string
        /// This will be shown as:
        /// msg 
        /// exception
        /// </summary>
        /// <param name="e">Exception</param>
        /// <param name="msg">Message</param>
        public void displayError(Exception e, String msg)
        {
            alert(msg + "\n" + e.Message.ToString());
        }

        /// <summary>
        /// Simple alert with only one line of text
        /// </summary>
        /// <param name="text">Message text</param>
        public void alert(String text)
        {
            MessageBox.Show(text);
        }

        /// <summary>
        /// Alert several lines
        /// </summary>
        /// <param name="list">List of strings to be displayed in the message</param>
        public void alert(List<string> list)
        {
            String cache = "";
            for (int i = 0; i < list.Count; i++)
            {
                cache = cache + "\n" + list[i];
            }
            alert(cache);
        }

        public string displayStatus(string status, int type)
        {
            if (type == STATUS_PROGRESS)
                return "Progress says we are here: " + status;
            else
                return status;
        }
    }
}
